export default {
    install(Vue, options) {
    	Vue.prototype.MenuOpen = false
    	Vue.prototype.getCookie = function(name) {
            let arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)")
            if (arr = document.cookie.match(reg))
                return unescape(arr[2])
            else
                return null
        }
        Vue.prototype.setCookie = function(c_name, value, expiredays) {
            var exdate = new Date()
            exdate.setDate(exdate.getDate() + expiredays)
            document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
        }
        Vue.prototype.delCookie = function(name) {
            var exp = new Date()
            exp.setTime(exp.getTime() - 1);
            var cval = this.getCookie(name);
            if (cval != null)
                document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString()
        }
         Vue.prototype.getdate = function(source) {
            var now = new Date(source),
                y = now.getFullYear(),
                m = now.getMonth() + 1,
                d = now.getDate();
            return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d)
        }
        Vue.prototype.getdatetime = function(source) {
            var now = new Date(source),
                y = now.getFullYear(),
                m = now.getMonth() + 1,
                d = now.getDate();
            return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8)
        }
		Vue.prototype.downLoadFile = function(link, name) {
	    	if(navigator.userAgent.indexOf("Firefox") > 0){
	    		const iframe = document.createElement("iframe")
			    iframe.style.display = "none";
			    iframe.src = link;
			    document.body.appendChild(iframe);
	    	}else{
	    		const aDom =document.createElement("a");
		        if(name){
		        	aDom.download = name;
		        }
		        aDom.href = link;
		        aDom.click();
	    	}
	    }
    }
}
